package com.sqfw.project.knowledge.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sqfw.project.knowledge.domain.KlOperationsLog;
import com.sqfw.project.knowledge.service.KlOperationsLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.web.page.TableDataInfo;

/**
 * 知识库操作日志Controller
 * 
 * @author tangxt
 * @date 2023-06-08
 */
@RestController
@RequestMapping("/klOperationsLog")
public class KlOperationsLogController extends BaseController
{
    @Autowired
    private KlOperationsLogService klOperationsLogService;

    /**
     * 查询知识库操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(KlOperationsLog klOperationsLog)
    {
        startPage();
        List<KlOperationsLog> list = klOperationsLogService.selectKlOperationsLogList(klOperationsLog);
        return getDataTable(list);
    }

    /**
     * 导出知识库操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "知识库操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KlOperationsLog klOperationsLog)
    {
        List<KlOperationsLog> list = klOperationsLogService.selectKlOperationsLogList(klOperationsLog);
        ExcelUtil<KlOperationsLog> util = new ExcelUtil<KlOperationsLog>(KlOperationsLog.class);
        util.exportExcel(response, list, "知识库操作日志数据");
    }

    /**
     * 获取知识库操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(klOperationsLogService.selectKlOperationsLogById(id));
    }

    /**
     * 新增知识库操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "知识库操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KlOperationsLog klOperationsLog)
    {
        return toAjax(klOperationsLogService.insertKlOperationsLog(klOperationsLog));
    }

    /**
     * 修改知识库操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "知识库操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KlOperationsLog klOperationsLog)
    {
        return toAjax(klOperationsLogService.updateKlOperationsLog(klOperationsLog));
    }

    /**
     * 删除知识库操作日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "知识库操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(klOperationsLogService.deleteKlOperationsLogByIds(ids));
    }
}
